/**
 * 返回首页
 */
function returnindex(){
	window.location.href="User_index";
}

/**
 * 确认修改密码
 */
function check(formid,requestUrl){
	//
	var result = SaveForm(formid, requestUrl);
	if(result == "success"){
		alert("保存成功");
		window.location.href="Login_loginPage";
	}else{
		if(result == "fail"){
			alert("原密码错误");
			
		}
	}
}
/**
 * 检查新密码两次输入的长度以及是否一样
 */
function checklength(){
	var newpassword=$("#newpassword").val();
	var renewpassword=$("#renewpassword").val();
	
	if(newpassword.length!=renewpassword.length){
		alert("两次的密码长度不一样！");
		$("#bt").hide(1010);
	}
	else if(newpassword!=renewpassword){
		alert("两次输入的密码不一样！");
		$("#bt").hide(1010);
	}else{
		$("#bt").toggle(1010);
	};
	
}

//保存数据
function saveuser(formid,requestUrl){
	
		var result = SaveForm(formid, requestUrl);
		if(result == "success"){
			alert("保存成功");
//			window.location.href="Login_loginPage";
		}else{
			alert("已存在该用户！");
		}
}

//修改数据
function update(formid,requestUrl){
	
	var result = SaveForm(formid, requestUrl);
	if(result=="success"){
		alert("修改成功!");
//		window.location.href="Login_loginPage";
	}else{
		alert("修改失败！");
	}
}

//返回上一个页面
function back(){
	window.location.href="User_addPage";
}

function deleteuser(va){
	$.ajax({
		type:"POST",
		url:"User_delete",
		data:{"user.cid":va},
		async: false,
			error: function(request) {
			alert("请求失败"+request.responseText);
			},
		success:function(data){
			result = String($.trim(data));
			if(result=="success"){
				alert("删除成功！");
				window.location.href="User_addPage";
			}else{
				alert("删除失败！")
			}
		}
	});
}

function backRight(){
	window.location.href="./jsp/right.jsp";
}
